<extend name="Base/common"/>

<block name="style">
    <link href="__CSS__/event.css" rel="stylesheet" type="text/css"/>
</block>
<block name="header">
    <include file="_nav"/>
</block>
<block name="body">

<!--导航-->
    <div class="col-xs-3 pull-right" style="z-index: 99">
        <include file="_right"/>
    </div>


    <div class="col-xs-9">
        <div class="forum_module " style="padding: 0";>
            <div class="clearfix">
                <div class="detail-title">
                    <div class="col-xs-10 text-more">
                        <a href="javascript:" onclick="location.href='{:U('Event/Index/detail',array('id'=>$content['id']))}'" title="{$content.title}">{$content.title}</a>
                    </div>
                    <div class="col-xs-2">
                        <i class="event_logo special-logo"></i>
                        <span class="event_count">{$content.view_count}</span>
                    </div>
                </div>
                <div class="col-xs-5 box-left">
                    <a class="pull-left" href="javascript:" onclick="location.href='{:U('Event/Index/detail',array('id'=>$content['id']))}'">
                        <img src="{$content.cover_id|getThumbImageById=345,250}"/>
                       <?php
                     $cover_path=getThumbImageById($content['cover_id']);
                       ?>
                        <div class="event_detail_type">{$content.type.title}</div>
                    </a>
                    <if condition="time() lt $content['eTime']">
                        <div class="event_state" style="background: #d61f39;">
                            {:L('_IN_PROGRESS_')}
                        </div>
                        <else/>
                        <div class="event_state" style="background: #000;">
                            {:L('_ALREADY_OVER_')}
                        </div>
                    </if>
                </div>

                <div class="col-xs-6 box-right">
                    <div class="event_fq_count pull-left">
                        <div class="box-name">
                            {:L('_SPONSOR_')}{:L('_COLON_')}
                            <a class="event_count" href="{$content.user.space_url}">{$content.user.nickname}</a>
                        </div>

                        <div class="mgt14 event_count" >{:L('_TIME_')}{:L('_COLON_')}
                            {:date('Y-m-d',$content['sTime'])}--{:date('Y-m-d',$content['eTime'])}
                        </div>

                        <div class="mgt14 event_count">{:L('_SITE_')}{:L('_COLON_')}
                            {$content.address}
                        </div>

                        <div class="mgt14 event_count">{:L('_DEADLINE_TIME_')}{:L('_COLON_')}
                            {:date('Y-m-d H:i',$content['deadline'])}
                        </div>

                        <div class="pull-left clearfix box-number">
                            <div class=" pull-left  mgt14">
                                <span class="event_count">{:L('_NUMBER_LIMIT_')}{:L('_COLON_')}{$content.limitCount}{:L('_PEER_')}</span>
                            </div>


                            <div class=" pull-left   mgt14">
                                <span class="event_count">{:L('_REGISTER_ED_')}{:L('_COLON_')}{$content.signCount}{:L('_PEER_')}</span>
                            </div>

                            <div class=" pull-left   mgt14">
                                <span class="event_count">{:L('_ALREADY_IN_')}{:L('_COLON_')}{$content.attentionCount}{:L('_PEER_')}</span>
                            </div>
                        </div>
                        <div class="pull-left  mgt14">
                            <div class="btn-group">

                                <php>if($content['uid'] == is_login() || is_administrator(is_login())){</php>

                                <if condition="time() lt $content['eTime']">
                                    <a id="endEvent" class="btn btn-default">{:L('_OVER_AHEAD_')}</a>
                                </if>

                                <a href="{:U('edit',array('id'=>$content['id']))}" class="btn btn-default">{:L('_EVENT_EDIT_')}</a>
                                <a id="delEvent" class="btn btn-default">{:L('_EVENT_DELETE_')}</a>
                                <php>}
                                    if($content['uid'] != is_login()){
                                    if(!$check_isSign){
                                    if($content['deadline'] < time()){</php>
                                <a class="btn btn-default  " href="javascript:"
                                   onclick="toast.error({:L('')})">{:L('_REGISTRATION_HAS_OVER_')} </a>
                                <php>}else{</php>
                                <if condition="is_login() eq 0">
                                    <a class="btn  btn-info   " href="javascript:"style="color: #fff"
                                       onclick="toast.error({:L('_ERROR_REGISTER_AFTER_LOGIN_')})">{:L('_REGISTER_OP_')} </a>
                                    <else/>
                                    <if condition="check_auth('Event/Index/doSign')">
                                        <a class="btn  btn-info  event_sign " style="color: #fff"
                                           href="{:U('ajax_sign',array('event_id'=>$content['id']))}">{:L('_REGISTER_OP_')} </a>
                                    </if>
                                </if>
                                <php>}
                                    }else{</php>
                                <a class="btn btn-default" href="javascript:"
                                   id="unSign">{:L('_REGISTER_CANCEL_')} </a>

                                <span style="line-height: 34px;float: left"> &nbsp;&nbsp;  {:L('_AUDIT_ED_')}&nbsp;&nbsp;<if
                                        condition="$check_isSign[0]['status'] eq 1">{:L('_AUDIT_ED_')}
                                    <else/>
                                    {:L('_AUDIT_OP_')}
                                </if></span>
                                <php>}
                                    }</php>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="title-box">
                {:L('_EVENT_DETAIL_')}
                <div class="share-box">
                    <div class="pull-right">
                        {:W('Common/Share/detailShare')}
                    </div>
                    <span class="pull-right">
                    {:W('Weibo/Share/shareBtn',array('param'=>array('img'=>$cover_path,'title'=>$content['title'],'content'=>$content['explain'],'from'=>$MODULE_ALIAS,'site_link'=>U('Event/Index/detail',array('id'=>$content['id']))),'text'=>"站内分享"))}
                    </span>
                </div>
            </div>

            <div class="word-wrap detail">
                {$content.explain|render}

                <div class="pull-right time">
                    {:L('_TIME_RELEASE_')}{:L('_COLON_')} {$content.create_time|friendlyDate} &nbsp;&nbsp;
                    {:L('_TIME_UPDATE_')}{:L('_COLON_')} {$content.update_time|friendlyDate}
                </div>

            </div>


            <div class="clearfix"></div>
            <div class="comment-box">
                {:hook('localComment', array('path'=>"Event/event/$content[id]", 'uid'=>$content['uid'],'count_model'=>'event','count_field'=>'reply_count','this_url'=>'event/index/detail'))}
            </div>
        </div>
    </div>
</block>

<block name="script">
    <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
    <script>
        $(function () {
            $('#top_nav >li >a ').mouseenter(function () {
                $('.children_nav').hide();
                $('#children_' + $(this).attr('data')).show();
            });


            $('.event_sign').magnificPopup({
                type: 'ajax',
                overflowY: 'scroll',
                modal: true,
                callbacks: {
                    ajaxContentAdded: function () {
                        console.log(this.content);
                    }
                }
            });



            /**
             * 取消报名
             * */
            $('#unSign').click(function () {
                if (confirm("{:L('_PROMPT_CANCEL_')}{:L('_QUESTION_')}")) {
                    var event_id = "{$content['id']}";
                    $.post("{:U('Event/Index/unSign')}", {event_id: event_id}, function (res) {
                        if (res.status) {
                            toast.success(res.info);
                            setTimeout(function () {
                                location.reload();
                            }, 1500);
                        }
                        else {
                            toast.error(res.info);
                        }
                    }, 'json');
                }
            });
            /**
             * 删除活动事件
             * */
            $('#delEvent').click(function () {
                if (confirm("{:L('_PROMPT_DELETE_')}{:L('_QUESTION_')}")) {
                    var event_id = "{$content['id']}";
                    $.post("{:U('Event/Index/doDelEvent')}", {event_id: event_id}, function (res) {
                        if (res.status) {
                            toast.success(res.info);
                            setTimeout(function () {
                                location.href = "{:U('index')}";
                            }, 1500);
                        }
                        else {
                            toast.error(res.info);
                        }
                    }, 'json');
                }
            });
            /**
             * 提前结束活动点击事件
             */
            $('#endEvent').click(function () {
                if (confirm("{:L('_PROMPT_OVER_')}{:L('_QUESTION_')}")) {
                    var event_id = "{$content['id']}";
                    $.post("{:U('Event/Index/doEndEvent')}", {event_id: event_id}, function (res) {
                        if (res.status) {
                            toast.success(res.info);
                            setTimeout(function () {
                                location.reload();
                            }, 1500);
                        }
                        else {
                            toast.error(res.info);
                        }
                    }, 'json');
                }
            });
        })
    </script>

</block>

